﻿using System.Web.UI.WebControls;
using Ue.Framework.Web.WebControls;
using Ue.Infrastructure.Web.UI;
using Ue.Qcdz.Domain.ShopArticle;
namespace Ue.Qcdz.UI.Controls
{
    /// <summary>
    /// 商铺 新闻 显示
    /// </summary>
    public class ShopNewsShow : SkinnedControl
    {
        private Literal ltrTitle;
        private Literal ltrEditor;
        private Literal ltrReference;
        private Literal ltrContent;
        private Literal ltrRemark;
        private Literal ltrCreateOn;

        protected override string GetSkinFileName()
        {
            return "";
        }

        protected override void InitializeSkin(System.Web.UI.Control skin)
        {
            ltrTitle = skin.FindControl<Literal>("ltrTitle");
            ltrRemark = skin.FindControl<Literal>("ltrRemark");
            ltrReference = skin.FindControl<Literal>("ltrReference");
            ltrContent = skin.FindControl<Literal>("ltrContent");
            ltrEditor = skin.FindControl<Literal>("ltrEditor");
            ltrCreateOn = skin.FindControl<Literal>("ltrCreateOn");
            //
            BindToControl();
        }

        private void BindToControl()
        {
            string key = Domain.SiteContext.GetSiteContext().NewsId;
            ShopNews model = ShopNewsService.GetShopNews(key);
            if (model != null)
            {
                if (model == null) return;
                if (this.ltrTitle != null)
                    ltrTitle.Text = this.Page.Title = model.Title;
                if (this.ltrRemark != null)
                    ltrRemark.Text = model.Remark;
                if (this.ltrReference != null)
                    ltrReference.Text = model.Reference;
                if (ltrContent != null)
                    ltrContent.Text = model.Content;
                if (ltrCreateOn != null)
                    ltrCreateOn.Text = model.CreateOn.ToShortDateString();
                if (ltrEditor != null)
                    ltrEditor.Text = model.Editor;
            }
        }
    }
}
